<#include "../include_page/templateTree.html"/>
<div class="pageContent">
	<div layoutH="0" style="float:left; display:block; overflow:auto; width:240px;border-right:solid 1px #CCC; line-height:21px;">
		<ul class="tree treeFolder">
			<@templateTree 'cmsTemplate' ''/>
	     </ul>
	     <script>
			$('a[href="cmsTemplate/list.html?queryPath=${(queryPath!)?url?js_string}<#if isFile??>&isFile=true</#if>"]',navTab.getCurrentPanel()).parent().addClass('selected');
		</script>
	</div>
	<div class="unitBox" style="margin-left:240px;">
		<#if isFile??>
			<#if meta??>
				<h2 class="contentTitle"><@t.m 'moudle.template'/>元数据</h2>
				<#assign meta=getTemplateMetadata(queryPath)/>
				<div class="pageContent">
					<form method="post" action="cmsTemplate/update.do?navTabId=cmsTemplate" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
						<input name="path" type="hidden" value="${queryPath?html}"/>
						<div class="pageFormContent" layoutH="94" style="background:#ffffff;">
							<dl class="nowrap">
								<dt>别名:</dt></dt>
								<dd>
									<input name="alias" type="text" maxlength="50" size="50" value="${(meta.alias)!}"/>
								</dd>
							</dl>
							<dl class="nowrap">
								<dt>发布<@t.m 'moudle.path'/>:</dt>
								<dd>
									<input name="targetpath" type="text" maxlength="50" size="50" value="${(meta.path)!}"/>
								</dd>
							</dl>
							<dl class="nowrap">
								<dt>关键词:</dt>
								<dd>
									<input name="keywords" type="text" maxlength="200" size="50" value="${(meta.keywords)!}"/>
								</dd>
							</dl>
							<dl class="nowrap">
								<dt>描述:</dt>
								<dd>
									<input name="description" type="text" maxlength="200" size="50" value="${(meta.description)!}"/>
								</dd>
							</dl>
						</div>
						<div class="formBar">
							<ul>
								<li>
									<a class="buttonActive" href="cmsTemplate/list.html?queryPath=${(queryPath!)?url}&isFile=true" target="navTab" rel="cmsTemplateCreate">
										<span><@t.m 'moudle.template'/><@t.m 'moudle.content'/></span>
									</a>
								</li>
								<li>
									<div class="buttonActive">
										<div class="buttonContent"><button type="submit"><@t.m 'button.save'/></button></div>
									</div>
								</li>
							</ul>
						</div>
					</form>
				</div>
			<#else>
<#macro includeTemplateTree filepath='/include'>
	<@_templateList path=filepath exclude='true'>
		<#if list?has_content>
		<#list list as a>
		<li>
			<#local queryPath=filepath+'/'+a.fileName>
		<#if a.directory>
			<a href="javascript:;">${a.fileName}${(a.alias?has_content)?then('(${a.alias!})','')}</a>
			<ul>
				<@includeTemplateTree queryPath/>
			</ul>
		<#else>
			<a href="javascript:;" onclick="$('textarea[name=content]',navTab.getCurrentPanel()).insertAtCaret('${('<!--#include virtual="'+queryPath+'"-->')?html?js_string}${(a.alias?has_content)?then('<#-- ${a.alias!} -->','')?html}');">
				${a.fileName}${(a.alias?has_content)?then('(${a.alias!})','')}
			</a>
		</#if>
		</li>
		</#list>
		<#else>
			<li><a>空目录</a></li>
		</#if>
	</@_templateList>
</#macro>
				<h2 class="contentTitle">
					<@t.m 'moudle.template'/><@t.m 'moudle.content'/>
				</h2>
				<div class="pageContent">
					<form method="post" action="cmsTemplate/save.do?navTabId=cmsTemplate" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
						<div class="pageFormContent" layoutH="97">
							<input name="path" type="hidden" value="${queryPath?html}"/>
							<div style="float:right;width:238px;">
								<h3 class="contentTitle">点击使用页面片段</h3>
								<ul class="tree treeFolder" style="border:solid 1px #CCC;">
									<@includeTemplateTree/>
							    </ul>
								<#if !queryPath??||!queryPath?starts_with('/include/')>
									<a class="buttonActive" href="cmsTemplate/add.html?navTabId=cmsTemplate&queryPath=${('/include'+(queryPath!)+'/')?url}&userTemplate" target="navTab" rel="cmsTemplateCreate"><span>创建推荐位</span></a>
									<a class="buttonActive" href="cmsTemplate/add.html?navTabId=cmsTemplate&queryPath=${'/include/'?url}" target="navTab" rel="cmsTemplateCreate"><span>创建代码片段</span></a>
								</#if>
								<a class="buttonActive" href="javascript:$('textarea[name=content]',navTab.getCurrentPanel()).insertAtCaret('\t');"><span>插入制表符</span></a>
							</div>
							<div style="margin-right:240px;height:100%;">
								<textarea name="content" class="required" style="width:100%;height:100%;padding:0px;">${(getTemplateContent(queryPath)?html)!}</textarea>
							</div>
						</div>
						<div class="formBar">
							<ul>
								<li>
									<a class="buttonActive" href="cmsTemplate/list.html?queryPath=${(queryPath!)?url}&isFile=true&meta" target="navTab" rel="cmsTemplateCreate">
										<span><@t.m 'moudle.template'/>元数据</span>
									</a>
								</li>
								<li>
									<div class="buttonActive">
										<div class="buttonContent"><button type="submit"><@t.m 'button.save'/></button></div>
									</div>
								</li>
							</ul>
						</div>
					</form>
				</div>
			</#if>
		<#else>
			<h2 class="contentTitle">
				<a class="buttonActive" href="cmsTemplate/add.html?navTabId=cmsTemplate&queryPath=${((queryPath!)+'/')?url}" target="navTab" rel="cmsTemplateCreate"><span>创建<@t.m 'moudle.template'/></span></a>
				<#if !queryPath??||!queryPath?starts_with('/include')><a class="buttonActive" href="cmsTemplate/add.html?navTabId=cmsTemplate&queryPath=${('/include/')?url}" target="navTab" rel="cmsTemplateCreate"><span>创建代码片段</span></a></#if>
			</h2>
		</#if>
	</div>
</div>